Skip to content

Bugfix: toArray method for Tensor2 and Tensor3 to handle axes of extent 0 correctly - #184

Merged
marcelluethi merged 1 commit into
dimwit-dev:mainfrom
marcelluethi:bugfix-array-dim-0
Nov 18, 2026
Merged

marcelluethi merged 1 commit into
dimwit-dev:mainfrom
marcelluethi:bugfix-array-dim-0

Conversation

@marcelluethi

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the zero-length-axis tensor conversion changes.

No open issues 🎉

What changed in this PR

Fixes Tensor2.toArray and Tensor3.toArray so tensors with zero-length axes produce correctly shaped nested arrays.

Changes:

  • Replaces grouping with shape-driven array construction, avoiding zero-sized groups and preserving empty inner dimensions.
  • Adds regression tests for zero extent on each axis of 2D and 3D tensors.
File Description
core/​src/​test/​scala/​dimwit/​tensor/​ToArraySuite.scala Adds zero-extent conversion tests for every axis.
core/​src/​main/​scala/​dimwit/​tensor/​tensorops/​Tensor3Extensions.scala Constructs 3D arrays using explicit axis extents and flat-data slices.
core/​src/​main/​scala/​dimwit/​tensor/​tensorops/​Tensor2Extensions.scala Constructs 2D arrays using explicit row and column extents.

Review effort: Balanced

@marcelluethi
marcelluethi merged commit 7854c2f into dimwit-dev:main Nov 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants